package com.lwy.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lwy.entity.BookComment;
import com.lwy.service.impl.BookCommentServiceImpl;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

//评论表controller控制层
@RestController
@RequestMapping("comment")
public class BookCommentController {

    @Resource
    private BookCommentServiceImpl bookCommentService;
    //查询小说评论
    @RequestMapping("list")
    public List<BookComment> getList(Integer nove_id,Integer chapter_id){
        return bookCommentService.getComment(nove_id,chapter_id);
    }
    //    评论数量
    @RequestMapping("count")
    public Integer count(Integer nove_id,Integer chapter_id){
        return bookCommentService.count(new QueryWrapper<BookComment>().eq("nove_id",nove_id).eq("chapter_id",chapter_id).eq("user_id",0));
    }
    //    修改
    @RequestMapping("edit")
    public boolean edit(BookComment bookComment){
        return bookCommentService.updateById(bookComment);
    }

    @RequestMapping("findById")
    public List<BookComment> findById(Integer id){
        return bookCommentService.findById(id);
    }

//    新增
    @RequestMapping("save")
    public boolean save(BookComment bookComment){
        return bookCommentService.save(bookComment);
    }


    @RequestMapping("upd")
    public boolean upd(BookComment bookComment){
        return bookCommentService.updateById(bookComment);
    }
}
